<template>
	<view class="content">
		<view class="title">
			选择预约的土地
		</view>
		<view class="main">
			<view class="title">
				土地选择
			</view>

			<!-- 				<view :class="item.isClick?'funcItem2':'funcItem'" v-for="item in list" :key="item.id"
					@click="onClickFunc(item)">
					{{ item.name }}
				</view> -->

			<view class="funcBox uni-px-5 uni-pb-5">
				<!-- <view class="text">多选选中：{{JSON.stringify(checkList)}}</view> -->
				<uni-data-checkbox mode="button" multiple v-model="checkList" :localdata="list"></uni-data-checkbox>
			</view>
			<view class="btn">
				<button @click="handleClickBtn">确定</button>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		checkReserve
	} from "../../request/api";

	export default {
		data() {
			return {
				checkList: [],
				opingData: {},
				list: [],
				isClick: false
			}
		},
		onShow() {
			// this.list.splice(0)
			this.getreserve()

		},
		methods: {
			getreserve() {
				checkReserve().then(res => {
					let data = Array.from(res.data.data)
					let list = []
					let flag
					for (const dataKey in data) {
						flag = true
						for (const listKey in list) {
							if (list[listKey].value === data[dataKey].landId) {
								flag = false
								break;
							}
						}
						if (flag) {
							list.push({
								isClick: false,
								text: data[dataKey].landName,
								value: data[dataKey].landId
							})
						}
					}
					this.list = list

				})


			},
			handleClickBtn() {

				var mynavData = JSON.stringify(this.checkList)
				console.log(mynavData);
				if (this.checkList.length <= 0) {
					uni.showToast({
						title: '请选择土地',
						icon: 'none'
					})
					return
				} else {

					uni.navigateTo({
						url: '/pages/trusteeship/trusteeship?landId=' + mynavData,
						fail(error) {
							console.log(error)
						}
					})
				}

			},
			handleChooseDay(day) {


			}
		},
	}
</script>

<style scoped lang="less">
	.dialog {
		width: 70vw;
		height: 60vw;
		position: absolute;
		left: 0;
		top: 0;

		.title {
			width: 70vw;
			height: 10vw;
			background-color: rgb(0, 122, 255);
			text-align: center;
			line-height: 10vw;
			font-size: 18px;
		}

		//noinspection CssInvalidPropertyValue
		.itemBox {
			display: flex;
			margin-top: 25rpx;
			margin-bottom: 25rpx;
			justify-items: center;
			flex-wrap: wrap;

			//noinspection CssInvalidPropertyValue
			.item {
				text-align: center;
				padding-left: 10rpx;
				padding-right: 10rpx;
				margin: 15rpx;
				min-width: 80rpx;
				min-height: 50rpx;
				line-height: 50rpx;
				border: rgba(0, 0, 0) solid 1rpx;
				border-radius: 5rpx;
			}
		}
	}

	.content {
		width: 100%;
		background-color: rgb(0, 122, 255);

		>.title {
			text-align: center;
			height: 15vh;
			line-height: 15vh;
			font-weight: 600;
			font-size: 1.5em;
			color: white;
		}

		.main {
			background-color: white;
			height: 75vh;
			border-top-right-radius: 20px;
			border-top-left-radius: 20px;
			display: flex;
			flex-flow: column;

			.title {
				color: black;
				left: 2em;
				font-size: 16px;
				font-weight: 600;
				height: 10vh;
				line-height: 15vh;
				margin-left: 2em;
			}

			.funcBox {
				display: flex;
				flex-wrap: wrap;
				justify-content: center;
				text-align: center;
				padding-left: 10px;
				padding-right: 10px;

				.funcItem {
					display: flex;
					justify-content: center;
					margin: 1.3vw;
					width: 28vw;
					height: 8vh;
					line-height: 8vh;
					background-color: rgba(200, 200, 200, 0.3);
					border-radius: 10px;
				}

				.funcItem2 {
					display: flex;
					justify-content: center;
					margin: 1.3vw;
					width: 28vw;
					height: 8vh;
					line-height: 8vh;
					background-color: rgba(200, 200, 200, 0.7);
					color: #007aff;
					border-radius: 10px;
				}
			}

			.btn {
				position: absolute;
				bottom: 2em;
				display: flex;
				left: 50%;
				transform: translate(-50%);

				button {
					background-color: rgb(0, 122, 255);
					color: white;
					width: 30vw;
				}
			}
		}
	}

	.text {
		font-size: 12px;
		color: #666;
		margin-top: 5px;
	}

	.uni-px-5 {
		padding-left: 10px;
		padding-right: 10px;
	}

	.uni-pb-5 {
		padding-bottom: 10px;
	}
</style>
